package com.sbpm.crmbpm.client.application.dict;

import com.sbpm.crmbpm.shared.data.dict.City;
import com.sbpm.crmbpm.shared.data.dict.Country;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Dictionaries
{
    public static Map<String, Country> COUNTRIES;
    public static Map<Country, Map<String, City>> CITIES;

    public static void loadCitiesAndCountries( List<City> cities )
    {
        COUNTRIES = new HashMap<String, Country>();
        CITIES = new HashMap<Country, Map<String, City>>();
        for ( City city : cities )
        {
            Country country = city.getCountry();
            if( COUNTRIES.get( country.getName() ) == null )
            {
                COUNTRIES.put( country.getName(), country );
                CITIES.put( country, new HashMap< String, City >() );
            }
            CITIES.get( country ).put( city.getName(), city );
        }
    }

}
